<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务，帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件，不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);

namespace app\api\model\jia;
use app\common\model\jia\BuildChange as BuildChangeModel;
use app\api\service\User as UserService;
use think\facade\Db;
/**
 * 商家门店模型
 * Class Shop
 * @package app\store\model\store
 */
class BuildChange extends BuildChangeModel {
	/**
	 * 隐藏字段
	 * @var array
	 */
	protected $hidden = [
		'is_delete',
		'store_id',
		'create_time',
		'update_time',
	];
	public function add($orderId, array $data) {
		// 当前用户信息
		$user = UserService::getCurrentLoginUser(true);
		$manage = Db::name('store_shop_manage')
			->where('user_id', $user['user_id'])
			->where('is_delete', 0)->where('status', 1)->field('clerk_id,real_name')->find();
		$data['order_id'] = $orderId;
		$this->save([
			'order_id' => $data['order_id'],
			'manage_id' => $manage['clerk_id'],
			'manage_name' => $manage['real_name'],
			'old_build' => $data['old_build'],
			'old_floor' => $data['old_floor'],
			'floor' => $data['floor'],
			'build' => $data['build_no'],
			'old_room' => $data['old_room'],
			'room' => $data['room'],
			'bed_no' => $data['bed_no'],
			'old_bed_no' => $data['old_bed_no'],
			'house_id' => isset($data['house_id'])?$data['house_id']:0,
			'old_shop' => $data['old_shop'],
			'shop' => $data['shopName'],
			'store_id' => self::$storeId,
		]);

		return true;
	}

}